#!/usr/bin/python
"""

    something.py
    [--quiet]
    [--log_file PATH]

"""

from optparse import OptionParser
import sys, os
import os.path
import re
import StringIO
import glob
import shutil

# add self to search path for testing
if __name__ == '__main__':
    exe_path = os.path.split(os.path.abspath(sys.argv[0]))[0]
    sys.path.append(os.path.abspath(os.path.join(exe_path,"..", "python_modules")))
    myname = os.path.split(sys.argv[0])[1]
    myname = os.path.splitext(myname)[0];
else:
    myname = __name__

import general_util
from general_util import die_error



parser = OptionParser(version="%prog 1.0")
parser.add_option("-v", "--verbose", dest = "verbose",
                  action="store_true", default=False,
                  help="Do not echo to shell but only print to log.")


# get help string
f =StringIO.StringIO()
parser.print_help(f)
helpstr = f.getvalue()
(options, args) = parser.parse_args()





def  remove_line_endings_from_fasta():
    if options.verbose:
        sys.stderr.write("    [")
    sys.stdout.write(sys.stdin.readline())
    cnt_lines = 0
    cnt_dots  = 0
    for line in sys.stdin:
        cnt_lines += 1

        if cnt_lines % 200000 == 0:
            cnt_dots += 1
            if options.verbose:
                if cnt_dots % 50 == 0:
                    sys.stderr.write("\n    ")
                sys.stderr.write(".")


        # accession line preceded by new line and followed by new line
        if line[0] == '>':
            # print new line to terminate previous sequence
            sys.stdout.write("\n" + line)
        else:
            sys.stdout.write(line.strip())

    sys.stdout.write ("\n" )
    if options.verbose:
        sys.stderr.write ("]\n")


remove_line_endings_from_fasta()
